(c-forward-syntactic-ws): Fixed a bug that could cause an infinite
authorMartin Stjernholm <mast@lysator.liu.se>
Tue, 20 Aug 2002 21:58:51 +0000 (21:58 +0000)
committerMartin Stjernholm <mast@lysator.liu.se>
Tue, 20 Aug 2002 21:58:51 +0000 (21:58 +0000)
loop if something that looks like a macro begins in the middle of a
line.

(c-parse-state): Fixed a bug that could cause `c-state-cache' to
contain two conses in sequence when there's an unbalanced open paren
in a macro.

lisp/progmodes/cc-engine.el

index 3994c5cc22cf71901e7d407757eea86936fcade2..4fdfbcf950218c350628630d1b551f77ca46380a 100644 (file)
@@ -642,8 +642,9 @@ specified."
        (forward-char))
        ;; Skip preprocessor directives.
        ((and (looking-at "#[ \t]*[a-zA-Z0-9!]")
-            (progn (skip-chars-backward " \t")
-                   (bolp)))
+            (save-excursion
+              (skip-chars-backward " \t")
+              (bolp)))
        (end-of-line)
        (while (and (<= (point) lim)
                    (eq (char-before) ?\\)
@@ -1245,6 +1246,11 @@ you need both the type of a literal and its limits."
              (setq c-state-cache (cdr c-state-cache)))
          (setq pairs (car pairs))
          (setcar pairs (1- (car pairs)))
+         (when (consp (car-safe c-state-cache))
+           ;; There could already be a cons first in `c-state-cache'
+           ;; if we've jumped over an unbalanced open paren in a
+           ;; macro below.
+           (setq c-state-cache (cdr c-state-cache)))
          (setq c-state-cache (cons pairs c-state-cache)))
        (if last-pos
            ;; Prepare to loop, but record the open paren only if it's